﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ParsingProject
{
    public class TabBasedParser : IParser
    {
        public List<List<string>> Parse(string path)
        {
            List<List<string>> result = new List<List<string>>();
            ParserHelper.ReadFile(path);

            if (!ParserHelper.ReadFile(path))
                return null;

            while (!ParserHelper.EndOfStream(path))
            {
                List<string> line = new List<string>();
                string[] cells = ParserHelper.ReadAndParseLine(path, '\t');

                for (int i = 0; i < cells.Count(); ++i)
                {
                    cells[i] = cells[i].Replace(',', '-');
                }

                line.AddRange(cells);
                result.Add(line);
            }

            ParserHelper.CloseReadFile(path);

            return result;
        }
    }
}
